<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>开始订单</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/driver.js"></script>
    <script src="../../js/common.js"></script>
</head>
<body>
<section class="tabbtnarea">
    <li class="w50 rline" id="goStartBid">订单信息</li>
    <li class="w50"><span class="tabfouse">费用明细</span></li>
</section>
<section class="itemgroup mt44 p15">
    <div class="oneitem">
        <label class="gray">联系人:</label>
        <i class="iconfont rightsmallicon">&#xe6db;</i>
        <label class="right" id="consignName"></label>
    </div>
</section>
<section class="itemgroup mt10 p15">
    <div class="oneitem">
        <div class="gray left">总计行驶:</div>
        <div class="right"><label class="mr5" id="planDistance"></label>公里</div>
    </div>
    <div class="oneitem">
        <div class="gray left">起步价(含<span id="exceedDistance"></span>公里内):</div>
        <div class="right"><label class="red mr5" id="planStartFee"></label>元</div>
    </div>
    <div class="oneitem" style="display:none;">
        <div class="gray left">超里程费(<span id="exceedDistance1"></span>公里外):</div>
        <div class="right"><label class="red mr5" id="planExceedFee"></label>元</div>
    </div>
    <div class="oneitem" style="display:none;" id="placeDateDiv">
        <div class="gray left">起运时间:</div>
        <div class="right"><label class="mr5" id="placeDate">00:00</label></div>
    </div>
    <div class="oneitem" style="display:none;" id="unloadDateDiv">
        <div class="gray left">到达时间:</div>
        <div class="right"><label class="mr5" id="unloadDate">00:00</label></div>
    </div>
    <div class="oneitem">
        <div class="gray left">超里程单价(<span id="exceedDistance2"></span>公里外):</div>
        <div class="right"><label class="red mr5" id="planExceedPrice"></label>元/公里</div>
    </div>
    <div class="oneitem">
        <div class="gray left">特殊需求(搬运):</div>
        <div class="right"><label class="red mr5" id="planSpecialFee"></label>元</div>
    </div>
    <div class="oneitem">
        <div class="gray left">等候时间:</div>
        <div class="right"><label class="red mr5" id="planWaitTime"></label></div>
    </div>
    <div class="oneitem" style="display:none;">
        <div class="gray left">装/卸货等待费用:</div>
        <div class="right"><label class="red mr5" id="planLoadFee"></label>元</div>
    </div>
    <div class="oneitem" style="display:none;">
        <div class="gray left">行驶途中等待费用:</div>
        <div class="right"><label class="red mr5" id="planLowSpeedFee"></label>元</div>
    </div>
</section>
<section class="detialbottom">
		<button type="button" class="right btn addcert_det" style="display:none;" onclick="startPrintDo()" id="tellCustPay">打印发票</button>
    <div class="cart_clear2 ml15">
        <span class="font12" id="feeText">预计向客户索取费用:</span>
        <span class="red font16" id="planTotalFee"></span>
    </div>
</section>
<script type="text/javascript">
    $(function () {
        //token验证
        checkDriverToken();
    });
    var waybillId = "";
    var placeDate = "";
    var unloadDate = "";
    var totalFee = "";
    var distance = "";
    var startFee = "";
    var waitingTime = "";
    var vehicleNum = "";
    var specialFee = "";//搬运费
    var hignRoadFee = "";//过路费
    var driverNumber = "";//司机服务卡号
    $(document).ready(function () {
        waybillId = GetArgsFromHref("waybillId");
        var url = _global.serverHost + "/driver/start_bid.htm";
        var data = {waybillId: waybillId};
        _callAjaxRequest(url, data, startBidBack);

        function startBidBack(data) {
        	if(data.waybill.status>70){
        		$("#goStartBid").attr("onclick", "goStartBid('" + data.waybill.waybillId + "')");
            $("#consignName").html(data.waybill.consignName == "" ? data.waybill.consignMobile : data.waybill.consignName);
            $("#planDistance").html(data.waybill.distance);
            distance = data.waybill.distance;
            $("#planStartFee").html(data.waybill.startFee);
            startFee = data.vehiclePrice.pv3;
            $("#planExceedFee").html(data.waybill.exceedFee);
            $("#planSpecialFee").html(data.waybill.specialFee);
            $("#planLowSpeedFee").html(data.waybill.lowSpeedFee);
            $("#planLoadFee").html(data.waybill.planLoadFee*1+data.waybill.planUnloadFee*1);
            $("#planTotalFee").html("￥" + data.waybill.totalFee);
            totalFee = data.waybill.totalFee;
            var ln_planWaitTime=data.waybill.lowSpeedTime+data.waybill.unloadTime;
            if(data.waybill.loadTime>600){//超过10分钟=600秒
            	ln_planWaitTime=ln_planWaitTime+data.waybill.loadTime-600;
            }
            waitingTime =ln_planWaitTime;
            $("#planWaitTime").html(Number(ln_planWaitTime*60).formatTime());
            $("#planExceedPrice").html(data.vehiclePrice.pv3);
            
            $("#placeDate").html(data.waybill.placeDate);
            placeDate = data.waybill.placeDate;
            $("#unloadDate").html(data.waybill.unloadDate);
            unloadDate = data.waybill.unloadDate;
            vehicleNum = data.waybill.vehicleNum;
            specialFee = data.waybill.specialFee;
            hignRoadFee = data.waybill.hignRoadFee;
            driverNumber = data.waybill.driverNumber;
            
            $("#exceedDistance").html(data.vehiclePrice.pv5);
            $("#exceedDistance2").html(data.vehiclePrice.pv5);
            
            $("#placeDateDiv").show();
            $("#unloadDateDiv").show();
            $("#feeText").html("向客户索取费用:");
            $("#tellCustPay").show();
        	}else{
            $("#goStartBid").attr("onclick", "goStartBid('" + data.waybill.waybillId + "')");
            $("#consignName").html(data.waybill.consignName == "" ? data.waybill.consignMobile : data.waybill.consignName);
            $("#planDistance").html(data.waybill.planDistance);
            $("#planStartFee").html(data.waybill.planStartFee);
            $("#planExceedFee").html(data.waybill.planExceedFee);
            $("#planSpecialFee").html(data.waybill.planSpecialFee);
            $("#planLowSpeedFee").html(data.waybill.planLowSpeedFee);
            $("#planLoadFee").html(data.waybill.planLoadFee*1+data.waybill.planUnloadFee*1);
            $("#planTotalFee").html("￥" + data.waybill.planTotalFee);
            var ln_planWaitTime=data.waybill.planLoadTime-10+data.waybill.planLowSpeedTime+data.waybill.planUnloadTime;
            $("#planWaitTime").html(Number(ln_planWaitTime*60).formatTime());
            $("#planExceedPrice").html(data.vehiclePrice.pv3);
            
            $("#exceedDistance").html(data.vehiclePrice.pv5);
            $("#exceedDistance2").html(data.vehiclePrice.pv5);
          }
        }
    });
    function goStartBid(waybillId) {
        window.location.href =  "../start_bid/start_bid.html?waybillId=" + waybillId;
    }
    
    function startPrintDo() {
        try{
        		if(driverNumber==""){
        			driverNumber = "123456";
        		}
		        alert(delegate.startPrint(waybillId+"",totalFee,placeDate,
		        unloadDate,distance,startFee,waitingTime,vehicleNum,specialFee,hignRoadFee,driverNumber));
		    }catch(e){}
    }
</script>
</body>
</html>